package pe.edu.upc.dsd.jjjar.upcbank.client;

import pe.edu.upc.dsd.jjjar.upcbank.client.mvc.AppController;

import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.util.Theme;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class BancoUPC implements EntryPoint {
	

	public static final String AFILIACION_SERVICE = "bancoupc/afiliacion.rpc";
	public static final String LOGIN_SERVICE = "bancoupc/login.rpc";
	
	
	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		
		GXT.setDefaultTheme(Theme.BLUE, true);
		

		// Login Service
		LoginServiceAsync loginservice = (LoginServiceAsync) GWT.create(LoginService.class);
		ServiceDefTarget endpoint = (ServiceDefTarget) loginservice;
	    endpoint.setServiceEntryPoint(LOGIN_SERVICE);
	    Registry.register(LOGIN_SERVICE, loginservice);
		
		// Articulo Service
		AfiliacionServiceAsync articuloservice = (AfiliacionServiceAsync) GWT.create(AfiliacionService.class);
	    endpoint = (ServiceDefTarget) articuloservice;
	    endpoint.setServiceEntryPoint(AFILIACION_SERVICE);
	    Registry.register(AFILIACION_SERVICE, articuloservice);
		
	    
	    	    
	    Dispatcher dispatcher = Dispatcher.get();
	    dispatcher.addController(new AppController());
	    dispatcher.addController(new AfiliacionController());
	    dispatcher.dispatch(AppEvents.Login);
	    
	    GXT.hideLoadingPanel("loading");
		
	}
	
	public static void showPage(EventType event){
		Dispatcher.forwardEvent(event);
	}

}
